import Vue from 'vue'
import Router from 'vue-router'
import Game from '@/components/game'
import Login from '@/components/login'
import Player from '@/components/player'

Vue.use(Router)

// 解决路由重复跳转
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/game',
      name: 'game',
      component: Game
    },
    {
      path: '/',
      name: 'login',
      component: Login
    },
    {
      path: '/player',
      name: 'player',
      component: Player
    },
  ],
})
